<template>
  <div>
    <h2>我是About的内容</h2>
  </div>
</template>

<script>
export default {
  name: "About",
  //组件内路由守卫
  beforeRouteEnter(to, from, next) {
    console.log("beforeRouteEnter", to, from);
    if (to.meta.isAuth) {
      //判断当前路由是否需要进行权限控制
      if (localStorage.getItem("school") === "atguigu") {
        //权限控制的具体规则
        next();
      } else {
        alert("学校名称不对，无权限！");
      }
    } else {
      next(); //放行
    }
  },
  beforeRouteLeave(to, from, next) {
    console.log("beforeRouteLeave", to, from);
    next();
  },
};
</script>
